for cntry = [55 50 51]
    ToDisp = cell(3,1);
    
    %------------------------------------------------------------------
    %Run regression with R11 and controls on the RHS
    FMcoef = NaN(T,7); Nstocks = NaN(T,1); adjR2 = NaN(T,1);
    for t = TFirst:T
        Y = Return(:,t);
        X = [Return11(:,t-2) MV(:,t-1) BM(:,t-1) GPtoAT(:,t-1) ATGrowth(:,t-1) Return(:,t-1)];
        idx = isfinite(Y) & all(isfinite(X),2) & CountryRegionDummy(:,cntry) & ~IsREIT & ~IsMicro(:,t-2,cntry);
        if sum(idx)>MinStocks

            % winsorize across all stocks
            if WinsorizeYRet
                y = winsorize(Y(idx),WinsorLevelY);
            else
                y = Y(idx);
            end
            x = winsorize(X(idx,:),WinsorLevelX);
            
            % neutralize country effects
            K = size(X,2);
            for cc = 1:49
                idx_cc = CountryRegionDummy(idx,cc);
                if sum(idx_cc) >= 1
                    for k = 1:K
                        x(idx_cc,k) = x(idx_cc,k) - mean(x(idx_cc,k),'omitnan');
                    end
                end
            end
            
            % standardize across all stocks
            xs = standardize(x);
            xs2 = [xs(:,1:2) xs(:,1).*xs(:,2) xs(:,3:6)]; % no constant yet
            xx = [xs2 ones(length(y),1)];
            
            if any(sum(isfinite(xx))==0); continue; end
            if rank(xx) == size(xx,2)
                [bb,adjR2(t)] = myols_simple(xx,y); Nstocks(t) = length(y);
                FMcoef(t,:) = bb(1:7);
            end
        end
    end
    for sample = 1:3
        switch sample
            case 1, T1 = TFirst; T2 = T;
            case 2, T1 = TFirst; T2 = THalf;
            case 3, T1 = THalf+1; T2 = T;
        end
        m = squeeze(mean(FMcoef(T1:T2,:),'omitnan')); s = squeeze(std(FMcoef(T1:T2,:),'omitnan')); n = squeeze(sum(isfinite(FMcoef(T1:T2,:)))); tstat = sqrt(n).*m./s;
        ToDisp{sample} = [100*m(1);tstat(1);NaN(4,1); mean(Nstocks(T1:T2,:),'omitnan'); 100*mean(adjR2(T1:T2,:),'omitnan')];
    end
    
    %------------------------------------------------------------------
    %Run regression with R11, X, R11*X, and controls on the RHS
    for xvar = 1:7
        FMcoef = NaN(T,9); Nstocks = NaN(T,1); adjR2 = NaN(T,1);
        for t = TFirst:T
            Y = Return(:,t);
            if xvar == 1
                X = [Return11(:,t-2) XVARS(:,t-1,xvar) MV(:,t-1) GPtoAT(:,t-1) ATGrowth(:,t-1) Return(:,t-1)];
            else
                X = [Return11(:,t-2) XVARS(:,t-1,xvar) MV(:,t-1) BM(:,t-1) GPtoAT(:,t-1) ATGrowth(:,t-1) Return(:,t-1)];
            end
            idx = isfinite(Y) & all(isfinite(X),2) & CountryRegionDummy(:,cntry) & ~IsREIT & ~IsMicro(:,t-2,cntry);
            if sum(idx)>MinStocks

                % winsorize across all stocks
                if WinsorizeYRet
                    y = winsorize(Y(idx),WinsorLevelY);
                else
                    y = Y(idx);
                end
                x = winsorize(X(idx,:),WinsorLevelX);
                
                % neutralize country effects
                K = size(X,2);
                for cc = 1:49
                    idx_cc = CountryRegionDummy(idx,cc);
                    if sum(idx_cc) >= 1
                        for k = 1:K
                            x(idx_cc,k) = x(idx_cc,k) - mean(x(idx_cc,k),'omitnan');
                        end
                    end
                end
                
                % standardize across all stocks
                xs = standardize(x);
                if xvar==3 % convert to residual analyst
                    ytemp = xs(:,2); xtemp = [ones(sum(idx),1) xs(:,3)];
                    xs(:,2) = ytemp - xtemp*(xtemp\ytemp);
                end
                if xvar == 1
                    xs2 = [xs(:,1:2) xs(:,1).*xs(:,2) xs(:,3) xs(:,1).*xs(:,3) xs(:,4:6)]; % no constant yet
                else
                    xs2 = [xs(:,1:2) xs(:,1).*xs(:,2) xs(:,3) xs(:,1).*xs(:,3) xs(:,4:7)]; % no constant yet
                end
                xx = [xs2 ones(length(y),1)];
                
                if any(sum(isfinite(xx))==0); continue; end
                if rank(xx) == size(xx,2)
                    [bb,adjR2(t)] = myols_simple(xx,y);
                    if xvar == 1
                        FMcoef(t,1:9) = [bb(1:5); NaN; bb(6:8)]; Nstocks(t) = length(y);
                    else
                        FMcoef(t,1:9) = bb(1:9); Nstocks(t) = length(y);
                    end
                end
            end
        end
        for sample = 1:3
            switch sample
                case 1, T1 = TFirst; T2 = T;
                case 2, T1 = TFirst; T2 = THalf;
                case 3, T1 = THalf+1; T2 = T;
            end
            m = squeeze(mean(FMcoef(T1:T2,:),'omitnan')); s = squeeze(std(FMcoef(T1:T2,:),'omitnan')); n = squeeze(sum(isfinite(FMcoef(T1:T2,:)))); tstat = sqrt(n).*m./s;
            D1 = []; for i = 1:3; D1 = [D1;100*m(i);tstat(i)]; end; D1 = [D1; mean(Nstocks(T1:T2,:),'omitnan'); 100*mean(adjR2(T1:T2,:),'omitnan')];
            ToDisp{sample} = [ToDisp{sample} D1];
        end
    end

    D = [ToDisp{1} NaN(8,1) ToDisp{2} NaN(8,1) ToDisp{3}];
    if cntry == 55
        writematrix(D,FileName, 'Sheet', SheetName, 'Range',Range1, 'AutoFitWidth',false);
    elseif cntry == 50
        writematrix(D,FileName, 'Sheet', SheetName, 'Range',Range2, 'AutoFitWidth',false);
    elseif cntry == 51
        writematrix(D,FileName, 'Sheet', SheetName, 'Range',Range3, 'AutoFitWidth',false);
    end
end
